#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int deleteAndEarn(vector<int>& nums) {
    int n = 10010;
    vector<int> arr(n + 10, 0);
    for (auto e : nums)
    {
        arr[e] += e;
    }

    vector<int> f(n + 10, 0);
    vector<int> g(n + 10, 0);
    for (int i = 1; i <= n; ++i)
    {
        f[i] = g[i - 1] + arr[i];
        g[i] = max(f[i - 1], g[i - 1]);
    }

    return max(f[n], g[n]);
}

int main()
{


	return 0;
}